// pages/transactionPage/buycoin/buycoin.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
      countTime:"09:59",
      Isfade:true,
      sale:0,
      zhifuLang:{}
  },
  daojishi(timer){
    let t = timer.split(':');
    let min = t[0].substring(1);
    let sec = t[1];
    sec -- ;
    if(sec<0){
      min--;
      sec = 59;
    }
    this.setData({
      countTime: sec < 10 ? 0 + '' + min + ':0' + sec : 0 + '' + min + ':' + sec
    })
   
    if(min==0 && sec==0){
      this.setData({
        countTime:"00:00",
        Isfade:false
      })
      clearInterval(this.timer);
    }
  },
  bindCopy(e){
    wx.setClipboardData({
      data: '￥65.6',
      success: function (res) {
        console.log(res);
        if (res.errMsg == 'setClipboardData:ok') {
          wx.showToast({
            title: '复制成功',
            icon: 'success',
            duration: 2000
          })
        }
      }
      })
  },
  contactT(e){
    console.log(e);
  },
  cancalOrder(e){
    clearInterval(this.timer);
    this.setData({
      Isfade:false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    let $this = this;
    // $this.daojishi($this.data.countTime)
    this.timer =  setInterval(function(){
        $this.daojishi($this.data.countTime)
      },1000)
    wx.setNavigationBarTitle({
      title: options.sale == 1 ? 'sell' : (options.sale == 2 ? '卖' : (options.sale == 3?"买":"buy"))
    })
    this.setData({
      sale:  options.sale || 0
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      zhifuLang: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'] : wx.T.locales['en']
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    clearInterval(this.timer);
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})